from time import sleep


from selenium import  webdriver

from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import  expected_conditions#

driver = webdriver.Chrome()

driver.get("http://192.168.1.138/ranzhi/www/sys/index.html")
driver.maximize_window()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="account"]')))
driver.find_element(By.XPATH, '//*[@id="account"]').send_keys("admin")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="password"]')))
driver.find_element(By.XPATH, '//*[@id="password"]').send_keys("123456")
driver.find_element(By.XPATH, '//*[@id="submit"]').click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="s-menu-1"]/button/img')))
driver.find_element(By.XPATH, '//*[@id="s-menu-1"]/button/img').click()
WebDriverWait(driver,10).until(expected_conditions.frame_to_be_available_and_switch_to_it("iframe-1"))
driver.find_element(By.XPATH, '//*[@id="mainNavbar"]/ul/li[4]/a').click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="browseForm"]/table/tbody/tr/td[11]/div/a')))
driver.find_element(By.XPATH, '//*[@id="browseForm"]/table/tbody/tr/td[11]/div/a').click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="browseForm"]/table/tbody/tr/td[11]/div/ul/li[5]/a')))
driver.find_element(By.XPATH, '//*[@id="browseForm"]/table/tbody/tr/td[11]/div/ul/li[5]/a').click()
sleep(2)
WebDriverWait(driver, 10).until( expected_conditions.alert_is_present())
alert = driver.switch_to.alert
sleep(1)
alert.dismiss()
driver.switch_to.parent_frame()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.LINK_TEXT,"签退")))
driver.find_element(By.LINK_TEXT,"签退").click()
sleep(1)



